<?php
/**
 * @package		Joomla.Site
 * @subpackage	mod_menu
 * @copyright	Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved.
 * @license		GNU General Public License version 2 or later; see LICENSE.txt
 */

// No direct access.
defined('_JEXEC') or die;
$user		= JFactory::getUser();
// Note. It is important to remove spaces between elements.

$is_user = false; 
$is_user_caterer = false; 
foreach ($user->groups as $key => $value){
        if($value==9) {
			$is_user_caterer = true; 
		}
		if($value==2) {
			$is_user = true; 
		}
}

?>
<script type="text/javascript">
	function logout(){
		if(confirm("Vil du virkelig ønsker at logge ud?")){
			jQuery('#f-logout').submit();
		}
	}
</script> 
<?php if ($user->get('guest')): ?>
	<?php // The user is not logged in. ?>
	<div class="nav-top-1">
		<ul>
			<li class="no-pad2"><a href="<?php echo JRoute::_('index.php?option=com_users&view=registration1'); ?>">Opret profil</a></li>
			<li class="no-pad1"><a href="<?php echo JRoute::_('index.php?option=com_users'); ?>">Login</a></li>
		 </ul>
	</div>
<?php else: ?>
	<?php // The user is already logged in.?>
	<div class="nav-top">
      <div class="un-here">
        <p>Du er logget ind som <span><?php echo $user->username; ?></span></p>
      </div>
      <!--.un-here-->
      <ul>
      	<?php
			$url_u = 'index.php?option=com_jobs&view=indhold';
			if($is_user_caterer) $url_u = 'index.php?option=com_jobs&view=indholdcaterer';
        ?>
        <li><a href="<?php echo JRoute::_($url_u);?>">Mit indhold</a></li>
        <li><a href="<?php echo JRoute::_('index.php?option=com_users&task=profile.edit&user_id='.(int) $user->id);?>">Min konto</a></li>
        <li class="no-pad"><a href="#" onclick="javascript:logout();">Log ud</a></li>
      </ul>
		<form name="f-logout" id="f-logout" action="<?php echo JRoute::_('index.php?option=com_users&task=user.logout'); ?>" method="post">
			<input type="hidden" name="return" value="<?php echo base64_encode(JURI::base()); ?>" />
			<?php echo JHtml::_('form.token'); ?>
		</form>
	</div>  
<?php endif; ?>
	
	 
<?php return; ?>
<ul class="menu<?php echo $class_sfx;?>"<?php
	$tag = '';
	if ($params->get('tag_id')!=NULL) {
		$tag = $params->get('tag_id').'';
		echo ' id="'.$tag.'"';
	}
?>>
<?php
foreach ($list as $i => &$item) :
	$class = 'item-'.$item->id;
	if ($item->id == $active_id) {
		$class .= ' current';
	}

	if (in_array($item->id, $path)) {
		$class .= ' active';
	}
	elseif ($item->type == 'alias') {
		$aliasToId = $item->params->get('aliasoptions');
		if (count($path) > 0 && $aliasToId == $path[count($path)-1]) {
			$class .= ' active';
		}
		elseif (in_array($aliasToId, $path)) {
			$class .= ' alias-parent-active';
		}
	}

	if ($item->deeper) {
		$class .= ' deeper';
	}

	if ($item->parent) {
		$class .= ' parent';
	}

	if (!empty($class)) {
		$class = ' class="'.trim($class) .'"';
	}

	echo '<li'.$class.'>';

	// Render the menu item.
	switch ($item->type) :
		case 'separator':
		case 'url':
		case 'component':
			require JModuleHelper::getLayoutPath('mod_menu', 'default_'.$item->type);
			break;

		default:
			require JModuleHelper::getLayoutPath('mod_menu', 'default_url');
			break;
	endswitch;

	// The next item is deeper.
	if ($item->deeper) {
		echo '<ul>';
	}
	// The next item is shallower.
	elseif ($item->shallower) {
		echo '</li>';
		echo str_repeat('</ul></li>', $item->level_diff);
	}
	// The next item is on the same level.
	else {
		echo '</li>';
	}
endforeach;
?></ul>
